/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.itcast.controller;

import com.itcast.pojo.User;
import com.itcast.service.FriendService;
import com.itcast.service.FriendServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author linnanxiang
 */
@WebServlet("/DeleteFriendsServlet")
public class DeleteFriendsServlet extends HttpServlet{

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String friendId=req.getParameter("friendId");
        FriendService friendService=new FriendServiceImpl();
        HttpSession session= req.getSession();
        User user=(User)session.getAttribute("user");
        friendService.DeleteFriend(user.getUserId(), friendId);
        resp.sendRedirect(getServletContext().getContextPath()+"/findFriendServlet");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
    
}
